#pragma once

#include <unistd.h>
#include <fcntl.h>
#include "Socket.hpp"
#include "../../../log-system/logs/clog.hpp"

using namespace clog;

void SetNonBlockOrDie(int sock)
{
    int f1 = fcntl(sock, F_GETFL);
    if (f1 < 0)
        exit(NON_BLOCK_ERR);

    fcntl(sock, F_SETFL, f1 | O_NONBLOCK);
}